﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CsharpTrainer.Core.JSON;
using Zeus.Thunder.Core;

namespace SharpTrainer.Other
{
    class JsonSerializeTest2 : ITestCase
    {
        public void Run()
        {
            string jsonA = "{ \"IDA\": 1, \"NameA\": \"A\", \"B\": { \"IDB\": 2, \"NameB\": \"B\" } }";
            string jsonB = "{ \"IDB\":1, \"NameB\": \"B\" }";
            string jsonC = "{ \"C\": [{ \"IDB\":1, \"NameB\": \"B\" }, { \"IDB\":2, \"NameB\": \"BB\" }] }";

            //通过字符串构建Json对象
            JsonObject newObj = new JsonObject(jsonA);
            JsonObject newObj2 = new JsonObject(jsonC);

            //通过属性类型对应的属性
            Console.WriteLine(newObj["B"].Object["IDB"].Value);
            Console.WriteLine(newObj["B"].Object["NameB"].Value);

            Console.WriteLine(newObj2["C"].Items[0].Object["NameB"].Value);
            Console.WriteLine(newObj2["C"].Items[1].Object["NameB"].Value);

        }
    }
}
